package utils

import (
	"net"
	"os"
)

const defaultEnv = "dev"

func GetRunEnv() string {
	args := os.Args
	if len(args) > 1 {
		return args[1]
	}
	return defaultEnv
}

func GetServerIP() (net.IP, error) {
	conn, err := net.Dial("udp", "8.8.8.8:80")
	defer conn.Close()

	if err != nil {
		return nil, err
	}

	addr := conn.LocalAddr().(*net.UDPAddr)
	return addr.IP, nil
}
